// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_MST_PERSON_MESSAGE
// * CreateDate    : 2011/8/16 10:16:40
// * Creater       : CodeSmith
// * LastChangeDate: 2011/8/16 10:16:40
// * LastChanger   : 2011/8/16 10:16:40
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Mst
{
/// <summary>
    /// MstPersonMessage
    /// </summary>
    public partial class MstPersonMessageBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objMstPersonMessageEntity">Entity</param>
        /// <returns>Entity</returns>
        public static MstPersonMessageEntity GetMstPersonMessage(MstPersonMessageEntity objMstPersonMessageEntity)
        {
            return DataAccess.SelectSingle<MstPersonMessageEntity>(objMstPersonMessageEntity);
        }
        public static List<MstPersonMessageEntity> GetMstPersonMessageByMessage(string messageId)
        {
            if (string.IsNullOrEmpty(messageId))
            {
                return null;
            }
            MstPersonMessageEntity entity = new MstPersonMessageEntity();
            entity.MessageId = messageId;
            return DataAccess.Select<MstPersonMessageEntity>(entity);
        }
        public static MstPersonMessageEntity GetMstPersonMessage(string messageId, string personId)
        {
            if (string.IsNullOrEmpty(messageId) || string.IsNullOrEmpty(personId))
            {
                return null;
            }
            MstPersonMessageEntity objMstPersonMessageEntity = new MstPersonMessageEntity();
            objMstPersonMessageEntity.MessageId = messageId;
            objMstPersonMessageEntity.PersonId = personId;
            return DataAccess.SelectSingle<MstPersonMessageEntity>(objMstPersonMessageEntity);
        }
        public static List<MstPersonEntity> GetToList(string messageId)
        {
            string sql = @"SELECT P.* 
                            FROM MST_PERSON P
                            INNER JOIN MST_PERSON_MESSAGE PM ON P.PERSON_ID = PM.PERSON_ID
                            WHERE PM.MESSAGE_ID = '" + messageId + "'";
            return DataAccess.Select<MstPersonEntity>(sql);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objMstPersonMessageEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertMstPersonMessage(MstPersonMessageEntity objMstPersonMessageEntity)
        {
            return DataAccess.Insert(objMstPersonMessageEntity);
        }

        public static bool InsertMstPersonMessage(List<MstPersonMessageEntity> objMstPersonMessageEntityList)
        {
            return DataAccess.Insert(objMstPersonMessageEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objMstPersonMessageEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateMstPersonMessage(MstPersonMessageEntity objMstPersonMessageEntity)
        {
            return DataAccess.Update(objMstPersonMessageEntity);
        }

        public static bool UpdateMstPersonMessage(List<MstPersonMessageEntity> objMstPersonMessageEntityList)
        {
            return DataAccess.Update<MstPersonMessageEntity>(objMstPersonMessageEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objMstPersonMessageEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteMstPersonMessage(MstPersonMessageEntity objMstPersonMessageEntity)
        {
            return DataAccess.Delete(objMstPersonMessageEntity);
        }

        public static bool DeleteMstPersonMessage(List<MstPersonMessageEntity> objMstPersonMessageEntityList)
        {
            return DataAccess.Delete<MstPersonMessageEntity>(objMstPersonMessageEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetMstPersonMessageAll()
        {
            return DataAccess.SelectAllDataSet<MstPersonMessageEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<MstPersonMessageEntity> GetMstPersonMessageAllList()
        {
            return DataAccess.SelectAll<MstPersonMessageEntity>();
        }
        #endregion
	}
	
	
}	

